package com.why.statistics;

import com.why.statistics.service.DailyService;
import com.why.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @program: guli_parent
 * @description:
 * @author: @why
 * @create: 2021-02-25 12:22
 **/
@Component
public class ScheduledTask {

    @Autowired
    private DailyService service;

    //每天6点完成前一天的数据添加
    @Scheduled(cron = "0 0 6 * * ?")
    public void ScheduledTask(){
        Date curDate = DateUtil.addDays(new Date(), -1);
        service.createStatisticsByDay(DateUtil.formatDate(curDate));
    }
}
